<%@ page import="com.oyb.entity.Student" %>
<%@ page import="java.util.List" %>
<%@ page import="com.oyb.entity.Admin" %><%--
  Created by IntelliJ IDEA.
  User: 11954
  Date: 2022/3/30
  Time: 23:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!-- 引入jstl标签 -->
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!-- 引入jstl的函数 -->
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<html>
<head>
    <title>查询学生</title>
</head>
<body>
<c:if test="${!fn:contains(login_user.power,'4')}">
    <c:redirect url="nopower.jsp"/>
</c:if>
<c:if test="${fn:contains(login_user.power,'1')}">
    <button onclick="javascript:location.href='StudentInsertQuery'">添加学生</button>
</c:if>
<c:if test="${fn:contains(login_user.power,'2')}">
    <button>删除学生</button>
</c:if>
<c:if test="${fn:contains(login_user.power,'3')}">
    <button>修改学生</button><br><br>
</c:if>
    <table border="1">
    <tr>
        <th>id</th>
        <th>姓名</th>
        <th>性别</th>
        <th>班级</th>
    </tr>
             <!-- 如果学生列表不等于空 -->
             <c:if test="${not empty pagestudent.datas}">
                 <c:forEach items="${pagestudent.datas}" var="student">
                     <tr>
                         <td>${student.id}</td>
                         <td>${student.name}</td>
                         <td>${student.sex == 1?"男":"女"}</td>
                         <td>${student.classes.class_name}(${student.classes.class_count})</td>
                     </tr>
                 </c:forEach>
             </c:if>
    </table>

<!-- 分页导航 -->
<c:if test="${pagestudent.page == 1}">
    <a href="#">首页</a>
    <a href="#">上一页</a>
</c:if>
<c:if test="${pagestudent.page > 1}">
    <a href="stuquerypage?page=1&pageSize=3">首页</a>
    <a href="stuquerypage?page=${pagestudent.page - 1}&pageSize=3">上一页</a>
</c:if>

<c:if test="${pagestudent.page == page.pageCount}">
    <a href="#">下一页</a>
    <a href="#">尾页</a>
</c:if>
<c:if test="${pagestudent.page < pagestudent.pageCount}">
    <a href="stuquerypage?page=${pagestudent.page + 1}&pageSize=3">下一页</a>
    <a href="stuquerypage?page=${pagestudent.pageCount}&pageSize=3">尾页</a>
</c:if>
<br>
第${pagestudent.page}页/共${pagestudent.pageCount}页

<a href="index.jsp">返回主页</a>
</body>
</html>
